﻿using System;
using System.Collections.Generic;
using System.Text;
using NUnit.Framework;
using System.Threading;
using System.Diagnostics;

namespace MobileManagement.Library
{
    [TestFixture]
    public class MobileManagementTest
    {
        [Test]
        public void MobileManagement_DoWork_Test()
        {
            MobileManagement myInstance = MobileManagement.Instance();
            myInstance.MobileNotActive += OnMobileNotActiveEvent;
            myInstance.StartWork();
            Thread.Sleep(15000);
            myInstance.StopWork();


        }


        private void OnMobileNotActiveEvent (Mobile m, EventArgs e)
        {
            Debug.WriteLine("EVENT DETECTED! -> "+m.ToString());
            /*SimpleAsynchronousExample saMail = new SimpleAsynchronousExample();
            ThreadPool.QueueUserWorkItem(new WaitCallback(saMail.enviarAlarmaServicioSinMoviles), m.ToString());
             * */
        }

        [Test]
        public void MergeMobile_Test()
        {
            MobileManagement myInstance = MobileManagement.Instance();
            if (!myInstance.ExistMobile("12345")) myInstance.InsertMobile("12345");
            if (!myInstance.ExistMobile("22165")) myInstance.InsertMobile("22165");
            myInstance.UpdateMobile("12345", DateTime.Now);
            myInstance.UpdateMobile("22165", DateTime.Now.AddHours(-4));
        }

        [Test]
        public void DeleteMobile_Test()
        {
            MobileManagement myInstance = MobileManagement.Instance();
            myInstance.DeleteMobile("12345");
            myInstance.DeleteMobile("22165");
        }
    }
}
